<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <style>
        body {
            /* 可以去除导航栏顶部的间隙 */
            margin: 0;
            /* background-image: url("https://p.ssl.qhimg.com/sdm/633_417_/t0111ac7b662effbfa1.jpg"); */
            background-image: url("../Resources/qiwutuanbackground.jpeg");
            background-repeat: no-repeat;
            background-size: 100%;
        }

        nav {
            display: flex;
            background: #f3f3f3;
            line-height: 2;
            justify-content: space-around;
            font-size: 18px;
        }

        @media screen and (max-width: 480px) {
            nav {
                flex-direction: column;
            }
        }

        /* 注册输入框部分错误提示 */
        .error {
            color: red;
        }

        input.error {
            border-color: red;
        }

        p {
            position: relative;
            margin-top: 20px;
        }

        .registerDiv {
            margin-left: 62%;
            margin-top: 15%;
            padding: 20px;
            height: 250px;
            color: black;
            background-color: white;
            width: 380px;
            border-radius: 25px;
        }

        p span {
            display: inline-block;
            width: 80px;
            text-align: right;
        }

        p input {
            position: absolute;
            left: 100px;
            width: 200px;
            height: 20px;
        }

        .pleaseInputSmsCode {
            /* 注意width 不指定的情况下 会继承自p input 部分设置的内容 */
            width: 100px;
        }

        .getSmsCode {
            position: relative;
            margin-left: 35px;
            width: 80px;
        }

        .submitButton {
            background-color: rgb(0, 181, 108);
            color: white;
            width: 200px;
            height: 40px;
            /* 取出按钮显示的灰色边框 */
            border: none;
            /* 去除选中的时候的边框 */
            outline: none;
            border-radius: 20px;
            /* position: absolute; left:100px; */
            position: relative;
            left: 50px;
        }
    </style>
</head>

<body>
    <nav class="nav">
        <!-- <a href="#" class="registerNav">注册帐号</a> -->
        <strong>注册帐号</strong>
        <!-- <h2>注册帐号</h2> -->
    </nav>
    <div class="registerDiv">
        <form>
            <p><span>
                    用户名：
                </span>
                <input type="text" placeholder="请输入要注册的用户名" id="accountName">
            </p>

            <p><span>
                    手机号：
                </span>
                <input type="text" , placeholder="请输入要注册的手机号" id="mobileNumber">
            </p>

            <p><span>
                    密码：
                </span>
                <input type="password" , placeholder="密码请设置8-20位的字符" , required id="password">
            </p>
            <p>
                <span>
                    验证码：
                </span>

                <input type="text" , placeholder="请输入短信验证码" class="pleaseInputSmsCode" id="pleaseInputSmsCode">
                <!-- <span>获取验证码</span> -->
                <input type="submit" value="获取验证码" class="getSmsCode">
                <br>
            </p>

        </form>

        <!-- onsubmit="registerFunction()" -->
        <input type="submit" , value="注册" class="submitButton" onclick="registerFunction()">
    </div>
</body>

<script>
    function registerFunction() {

        // 获取手机号 密码 用户名 短信验证码
        let accountName = getElementValue("accountName");
        let mobileNumer = getElementValue("mobileNumber");
        let password = getElementValue("password");
        let pleaseInputSmsCode = getElementValue("pleaseInputSmsCode");

        // 校验输入内容
        if (!accountName) {
            alert("请输入用户名");
            return;
        }
        if (!mobileNumer) {
            alert("请输入手机号");
            return;
        }
        if (!password) {
            alert("请设置密码");
            return;
        }
        if (!pleaseInputSmsCode) {
            alert("请输入短信验证码");
            return;
        }
        // window.open("./qiLogin.html","","_self");
        window.location.href = "./qiLogin.html";

        // alert(mobileNumer);
        // alert(password);
        // alert(accountName);
        // alert(pleaseInputSmsCode);
    }

    // 获取对应 id 的值
    function getElementValue(name) {
        console.log(document.getElementById(name).value);
        return document.getElementById(name).value;
    }
</script>

</html>